
﻿﻿﻿<script src="/Public/jsLibrary/jquery/jquery.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
﻿﻿﻿<script src="/Public/jsLibrary/Jslibary.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>房型管理</title>
<link href="/guanli/Inc/Css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
a {
	font-size: 12px;
}
</style>
</head>


<body>
客栈列表<br>

  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" >
  <Tr><TD>
<a href="/guanli/system/menusys/Sys_Add.php?MenuId=<{$MenuId}>&OwerID=&PMID=<{$Think.get.PMID}>&Title=添加客栈列表" target="_self"  class="Link12">添加房型</a>
 
 <a href="/guanli/system/price/Index.php?MenuId=612&PMID=<{$hid}>">进入时间段设置与管理</a>
 
 </td></tr>
</table>
<div style="margin-left:50px;">
    <div>请选择下面的时间段:
    <select name="choosetime" id="choosetime">
        <volist name="pricers" id="voprice">
       <option 
       <if condition="$pid eq $voprice['price0']">selected</if>
        value="<{$voprice['price0']}>::<{$voprice.price19}>"><{$voprice.price1}><{$voprice.price13|date="Y-m-d",###}>至<{$voprice.price14|date="Y-m-d",###}></option>
    </volist>
    </select>
    

    </div>
</div>
<table width="95%"  border="0" cellspacing="0" cellpadding="0" align="center">

 <form > <tr>
    <td width="30%">关键字：<input name="keyword" type="text" /> <input name="搜索" type="submit" value="搜索" /></td>
    <td width="67%"></td>
    <td width="3%">&nbsp;</td>
  </tr>
  </form>
</table>

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" class="YKTtable">
  <tr >
      <td width="45"  	 	 class="YKTth"><div align="center">ID</div></td>
     <td width="178"  	 	 class="YKTth">名称(房间类型)</td>
     <td width="58"  	 	 class="YKTth">市场价</td>
     <td width="61"  class="YKTth">梦之旅价</td>
	<td width="75"  class="YKTth">提前预定天数</td>
    <td width="91"  class="YKTth">定金支付比例</td>
    <td width="111"  class="YKTth">库存数</td>
     <td width="111"  class="YKTth">底价</td>
    <td width="165"   class="YKTth"><div align="center">日历价格设置</div></td>
 
   <td width="168"  class="YKTth"><div align="center">操 作</div></td>
  </tr>
<form action="<{:U('price/saveroomprice')}>" method="post" name="rform" id="rform">
 <volist name="rs" id="vo"> 
  <tr id="price<{$vo.hotelroom0}>" data="">

    <td class="YKTtd" ><div align="">
	<{$vo.hotelroom0}>	</div>
    </td>
    <td class="YKTtd" ><div align=""><{$vo.hotelroom1}>
    (<if condition="$vo.hotelroom4 eq '5755'">多床间<else />标准间</if>)
    
		</div>
    </td>
    <td class="YKTtd" ><div align=""><input name="marktprice<{$vo.hotelroom0}>" id="marktprice<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
    <td class="YKTtd" ><div align=""><input name="mzlprice<{$vo.hotelroom0}>" id="mzlprice<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
   <td class="YKTtd" ><div align=""><input name="tiqianyudin<{$vo.hotelroom0}>" id="tiqianyudin<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
 <td class="YKTtd" ><div align=""><input name="zhifubili<{$vo.hotelroom0}>" id="zhifubili<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
  <td class="YKTtd" ><div align=""><input value="" name="kucunshu<{$vo.hotelroom0}>" id="kucunshu<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
  <td class="YKTtd" ><div align=""><input name="dijia<{$vo.hotelroom0}>" id="dijia<{$vo.hotelroom0}>" type="text" size="4"></div>
    </td>
    
<td class="YKTtd" ><div align="">
	<a href="/inc/calendarprice.php?MenuId=<{$MenuId}>&hid=<{$hid}>&tid=<{$vo.hotelroom0}>&fieldid=12">日历价格设置</a>	</div>
    </td>
    <td class="YKTtd" ><div align="center">
		<a href="/guanli/system/menusys/Sys_Update.php?MenuId=<{$MenuId}>&ID=<{$vo.hotelroom0}>&CMID=&PMID=<{$hid}>&OwerID=<{$vo.hotelroom0}>&Title=修改客栈列表&CurrPage=">修改房型</a>
		
		| <a href="/guanli/system/menusys/Sys_Delete.php?MenuId=<{$MenuId}>&ID=<{$vo.hotelroom0}>&CMID=&PMID=<{$hid}>&OwerID=<{$vo.hotelroom0}>&Title=删除客栈列表">删除房型</a>
	
	</div></td>
</volist>
<input type="hidden" value="<{$pid}>" name="thispid" id="thispid">
<input type="hidden" value="<{$hid}>" name="hid" id="hid">
<input type="hidden" value="<{$MenuId}>" name="MenuId" id="MenuId">
<input type="hidden" value="<{$Think.get.PMID}>" name="PMID" id="PMID">
<input type="hidden" value="" name="zv" id="zv">
</form>
  </table>

<div align='right' style="margin-right:200px;"><input type="button" name="mysave" id="mysave" value="保 存">

</div>

<script>

$(document).ready(function(){
	//========================每次选择后就重新加载
	$("#choosetime").change(function(){
		checkIndex=$("#choosetime").val();
		tt=getkuohaostr(checkIndex,/^([\d]+)/);
		window.location.href="<{:U('hotelroom/listroom')}>/MenuId/<{$MenuId}>/hid/<{$hid}>/pid/"+tt+"/PMID/<{$Think.get.PMID}>";
	});
	
	//添加保存时的数据检查
	$("#mysave").bind("click",function(){
		var falg=0;//是否通过检查标识
		$("input[id^='marktprice']").each(function(){
			falg=0;
			id=$(this).attr("id");
			if(!nzeletype(id,"请输入正确的市场价","float")) return false;
			falg=1;
		});
		$("input[id^='mzlprice']").each(function(){
			falg=0;
			id=$(this).attr("id");
			if(!nzeletype(id,"请输入正确的梦之价","float")) return false;
			falg=1;
		});
		
		if(falg==0){
			return false;	
		}
		
		
		
		
		//=============================================组合值
		zvs="";//组合后的字符串
		
		$("tr[id^='price']").each(function(){
			pid=$(this).attr("id");
			pid=pid.replace("price","");
			zvs=zvs+"{id:"+pid+"}{scj:"+$("#marktprice"+pid).val()+"}{mzlj:"+$("#mzlprice"+pid).val()+"}{tiqianyudin:"+$("#tiqianyudin"+pid).val()+"}{zfbl:"+$("#zhifubili"+pid).val()+"}{dijia:"+$("#dijia"+pid).val()+"}{kucunshu:"+$("#kucunshu"+pid).val()+"},";
			
		});
		zvs=zvs.replace(/,$/,"");
		
		if(!zvs.match(/^[\{\w\:\.\,}]+$/)){
			alert("格式不对，请认真填写");
			return false;	
		}
		$("#zv").val(zvs);
		
		$("#rform").submit();

	});
	
	
	
	
	
	//当没有选定的时间段值时，初始化默认第一个的值
	pid="<{$pid}>";
	//var checkText=$("#chufaduan").find("option:selected").text();//获取选中的值,以便于右边计算
	
	if(pid!="0"){
		initsrr="<{$initarr.price19}>";
		inum=-1;
		if(initsrr!=""){
			initarr=initsrr.split(",");
			inum=initarr.length;
		}
		//=====================循环给相应的dom赋值
		
		$("input[id^='marktprice']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("marktprice","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{scj:([\d\.]+)\}/));	
					
			}
		});
		
		$("input[id^='mzlprice']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("mzlprice","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{mzlj:([\d\.]+)\}/));	
			}
		});
		
		$("input[id^='dijia']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("dijia","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{dijia:([\d\.]+)\}/));	
			}
		});
		
		
		$("input[id^='zhifubili']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("zhifubili","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{zfbl:([\d\.]+)\}/));	
			}
		});
		
		$("input[id^='tiqianyudin']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("tiqianyudin","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{tiqianyudin:([\d\.]+)\}/));	
			}
		});
		
		$("input[id^='kucunshu']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("kucunshu","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{kucunshu:([\d\.]+)\}/));	
			}
		});
		
		
	}
	
	
	
	if(pid=="0"){
		
		
		var firststr =$("#choosetime").get(0).options[0].value;//获取第一项的值
	    inum=-1;
		$("#thispid").val(getkuohaostr(firststr,/^([\d]+)/));
	    if(firststr!=""){
			firststr=firststr.replace(/^[\d]+\:\:/,"");
			initarr=firststr.split(",");
			inum=initarr.length;
		}
		//=====================循环给相应的dom赋值
		
		
		$("input[id^='marktprice']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("marktprice","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{scj:([\d\.]+)\}/));	
			}
		});
		
		$("input[id^='mzlprice']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("mzlprice","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{mzlj:([\d\.]+)\}/));	
			}
		});
		
		
		$("input[id^='dijia']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("dijia","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{dijia:([\d\.]+)\}/));	
			}
		});
		
		$("input[id^='zhifubili']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("zhifubili","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{zfbl:([\d\.]+)\}/));	
			}
		});
		
		
		$("input[id^='tiqianyudin']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("tiqianyudin","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{tiqianyudin:([\d\.]+)\}/));	
			}
		});
		$("input[id^='kucunshu']").each(function(){
			for(i=0;i<inum;i++){
					thisid=$(this).attr("id");
					thisid=thisid.replace("kucunshu","");
					temp=getkuohaostr(initarr[i],/\{id:([\d\.]+)\}/);
					if(temp==thisid) $(this).val(getkuohaostr(initarr[i],/\{kucunshu:([\d\.]+)\}/));	
			}
		});
		
	}
	
	
	//默认库存数,当没有库存数时，就默认房型里填写的值 显示格式为{id:值1}
	strl="{<volist name='rs' id='vo'><{$vo.hotelroom0}>:<{$vo.hotelroom8}>,</volist>}";
	$("input[id^='kucunshu']").each(function(){
		v=$(this).val();
		if(v==""){
			id=$(this).attr("id");
			id=id.replace("kucunshu","");
			
			aa=strl.match(/[\d]+\:[\d\.]*/g);
			if(aa!=null){
				numx=aa.length;
				
				for(k=0;k<numx;k++){
					
					tempjs=aa[k].match(/[\d]*$/);
					
					idn=getkuohaostr(aa[k],/([\d]+)\:/);
					if(idn==id && tempjs!=""){
						$(this).val(tempjs);	
					}
				}
			}
		}
		
	});
	
	
	
	
});
</script>
</body>
</html>
